﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Engine.Dtd.Configuration {
    /// <summary>
    /// Provides the catalog to map public identifier of external entity's to local files or other URI's.
    /// </summary>
    /// <remarks>
    /// <para>
    /// This section in an application configuration file defines an entity catalog
    /// that handles one simple case: mapping an external entity's public identifier
    /// to a URI reference.
    /// The catalog is a logical structure that contains 'mapping' information.
    /// The logical input to a catalog processor is an external public identifier.
    /// The logical output of the catalog processor is a URI reference.
    /// </para>
    /// <para>
    /// If a system identifiers of external entity's are preferred, a system identifier was provided,
    /// then the system identifier given in the external entity is used as the URI reference to locate the
    /// entity's replacement text.
    /// </para>
    /// </remarks>
    public sealed class EntityCatalogSection : ConfigurationSection {
        /// <summary>
        /// Gets the collection of external entity configuration elements.
        /// </summary>
        [ConfigurationProperty("public", IsDefaultCollection = false)]
        public PublicEntityCollection PublicEntities {
            get {
                return (PublicEntityCollection)this["public"];
                }
            }

        /// <summary>
        /// Gets or sets a value indicating whether public identifiers are prefered.
        /// </summary>
        /// <remarks>
        /// This property defines two modes of search strategy when an external identifier has an
        /// explicit system identifier.
        /// The two serch modes are 'public' and 'system'.
        /// <para>
        /// If system identifiers are preferred, then the system identifier is used as the storage object identifier
        /// regardless of the any public identifier.
        /// </para>
        /// <para>
        /// If public identifiers are preferred, the system identifier is used as the storage object identifier
        /// only if no mapping can be found in the catalog for the public identifier (if a public identifier was specified).
        /// </para>
        /// </remarks>
        /// <value>Default value is 'public'.</value>
        [ConfigurationProperty("prefer", IsRequired = true, DefaultValue = "public")]
        public string Prefer {
            get { return (string)this["prefer"]; }
            set { this["prefer"] = value; }
            }
        }
    }